The data in the LoveAndMoney.TXT file was collected by Shonda Kuiper. The variable Money represents the amount the individual spent last Valentine’s Day. The variable Love is a score on a satisfaction scale.
LoveMoney <- read.csv("LoveandMoney.csv")
head(LoveMoney)
## X Love MoneySpent
## 1 1 0 25.0
## 2 2 100 275.0
## 3 3 0 26.0
## 4 4 0 27.0
## 5 5 2 33.0
## 6 6 5 41.5
Plots and numeric descriptives of the individual variables are not particularly remarkable.
p_load(mosaic)
bwplot(~MoneySpent, data=LoveMoney)
bwplot(~Love, data=LoveMoney)
histogram(~MoneySpent, data=LoveMoney)
histogram(~Love, data=LoveMoney)
A scatterplot of MoneySpent as a function of Love indicates that there may be a linear relationship between the two variables.
xyplot(MoneySpent~Love,LoveMoney,pch=16,cex=1.5)
We fit the linear model.
LoveMoney.lm.l=lm(MoneySpent~Love,data=LoveMoney)
summary(LoveMoney.lm.l)
##
## Call:
## lm(formula = MoneySpent ~ Love, data = LoveMoney)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.9567 -2.9595 0.5433 3.2689 4.0476
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 25.94950 1.08919 23.82 <2e-16 ***
## Love 2.50014 0.01761 141.99 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.512 on 28 degrees of freedom
## Multiple R-squared: 0.9986, Adjusted R-squared: 0.9986
## F-statistic: 2.016e+04 on 1 and 28 DF, p-value: < 2.2e-16
The resultant model supports the strong relationship that was seen in the scatterplot. We follow the fitting of the linear model with a quick look at the residuals.
xyplot(LoveMoney.lm.l$resid~LoveMoney$Love,col="red",pch=16,cex=2)
plot(LoveMoney.lm.l)
Just a little reminder that the patterns hidden within “linear” relationships are not always linear.